package com.kuang.design.structural.adapter.obj;

import com.kuang.design.structural.adapter.EN_ZhTranslator;
import com.kuang.design.structural.adapter.Player;
import com.kuang.design.structural.adapter.Translator;


/**
 * 通过组合的方式：类结构模型，适配器转化到了翻译器功能上
 */
public class ZhMoviePlayerObjAdapter implements Player {

    private Player target;//被适配对象
    //组合方式
    private Translator translator=new EN_ZhTranslator();

    public ZhMoviePlayerObjAdapter(Player target) {
        this.target = target;
    }

    @Override
    public String play() {
        String play = target.play();
        //转换字幕 方法二：类直接继承翻译器
        String translate = translator.translate(play);
        return play;
    }
}
